<?php
// Tim'Roster
// Copyright (c) 2011 Nicolas Nallet <aspgic2@gmail.com>
//
// This file is part of Tim'Roster.
//
// Tim'Roster is free software; you can redistribute it and/or modify
// it under the terms of the GNU Affero General Public License as published by
// the Free Software Foundation; either version 3 of the License, or
// (at your option) any later version.
//
// Tim'Roster is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU Affero General Public License for more details.
//
// You should have received a copy of the GNU Affero General Public License
// along with this program; if not, write to the Free Software Foundation,
// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA

$xml_config = simplexml_load_file('config.xml');

include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/data_access/character_DA.php');
include_once($_SERVER["DOCUMENT_ROOT"].$xml_config->roster_root_directory.'/technical_class/language/language.php');



class Guild_Member{

    const GUILD_LEADER_GRADE_ID = 0;
    const GUILD_HIGH_OFFICER_GRADE_ID = 1;
    const GUILD_OFFICER_GRADE_ID = 2;
    const GUILD_MEMBER_GRADE_ID = 3;

    /**
     * (PHP 5)<br/>
     * Deserialize a guild member
     * @param SimpleXMLElement $xml
     */
    public function deserialize($xml){
        $this->name = $xml->name;
        $this->grade_id = $this->convert_grade_api_code_to_grade_id($xml->grade);
        $this->joined_date = date('Y-m-d H:i:s',intval($xml->joined_date)); // ryzom_time_txt(ryzom_time_array(intval($xml->joined_date)));
    }

    protected $id;
    /**
     * (PHP 5)<br/>
     * Get guild member id. This id come from the database
     * @return int
     */
    public function get_id(){
        return $this->id;
    }

    protected $name;
    /**
     * (PHP 5)<br/>
     * Get guild member name
     * @return string
     */
    public function get_name(){
            return $this->name;
    }

    protected $grade_id;
    /**
     * (PHP 5)<br/>
     * Get guild member grade id
     * @return int
     */
    public function get_grade_id(){
        return $this->grade_id;
    }
    /**
     * (PHP 5)<br/>
     * Get guild member grade label
     * @return string
     */
    public static function get_grade_label($id_grade){
        switch ($id_grade){
            case Guild_Member::GUILD_LEADER_GRADE_ID : return Language::get_instance()->get_label('lb_leader');
                break;
            case Guild_Member::GUILD_HIGH_OFFICER_GRADE_ID : return Language::get_instance()->get_label('lb_high_officer');
                break;
            case Guild_Member::GUILD_OFFICER_GRADE_ID : return Language::get_instance()->get_label('lb_officer');
                break;
            default : return Language::get_instance()->get_label('lb_member');
        }
    }

    protected $joined_date;
    /**
     * (PHP 5)<br/>
     * Get guild member joined date
     * @return date
     */
    public function get_joined_date(){
            return $this->joined_date;
    }

    protected $last_update_date;
    /**
     * (PHP 5)<br/>
     * Get guild member last update date
     * @return date
     */
    public function get_last_update_date(){
        return $this->last_update_date;
    }

    private $guild_name;
    /**
     * (PHP 5)<br/>
     * Get guild member guild name
     * @return string
     */
    public function get_guild_name(){
        return $this->guild_name;
    }

    private $guild_icon;
    /**
     * (PHP 5)<br/>
     * Get guild member guild icon
     * @return int
     */
    public function get_guild_icon(){
        return $this->guild_icon;
    }


    /**
     * (PHP 5)<br/>
     * Set guild member general information
     * @param int $id
     * @param string $name
     * @param int $grade_id
     * @param date $joined_date
     * @param date $last_update_date
     * @param string $guild_name
     * @param int $guild_icon
     */
    public function set_general_information($id, $name, $grade_id, $joined_date, $last_update_date, $guild_name, $guild_icon){
        $this->id = $id;
        $this->name = $name;
        $this->grade_id = $grade_id;
        $this->joined_date = $joined_date;
        $this->last_update_date = $last_update_date;
        $this->guild_name = $guild_name;
        $this->guild_icon = $guild_icon;
    }

    /**
     * (PHP 5)<br/>
     * Convert grade api code to grade id
     * @param string $grade_code
     * @return int
     */
    private function convert_grade_api_code_to_grade_id($grade_code){
        switch(strtolower($grade_code)) {
            case 'leader': return Guild_Member::GUILD_LEADER_GRADE_ID;
            case 'highofficer': return Guild_Member::GUILD_HIGH_OFFICER_GRADE_ID;
            case 'officer': return Guild_Member::GUILD_OFFICER_GRADE_ID;
            case 'member':
            default: return Guild_Member::GUILD_MEMBER_GRADE_ID;
        }
    }

    /**
     * (PHP 5)<br/>
     * Check if a character exists in the database
     * @param string $api_key
     * @param bool $is_crypted
     * @return bool
     */
    public static function exists($api_key, $character_name, $is_crypted){
        $pairs = Character::get_all_api_key();

        $key = $is_crypted ? ryzom_decrypt($api_key) : $api_key;


        if (isset($pairs)){
            foreach ($pairs as $pair){
                if (($key == ryzom_decrypt($pair[0])) || ($character_name == $pair[2])){ return true; }
            }
        }
        
        return false;
    }

    /**
     * (PHP 5)<br/>
     * Get all character api key in the db. Note that key are crypted
     * @return array of string
     */
    public static function get_all_api_key(){
        $da = new character_DA();

        return $da->get_all_api_key();
    }

    /**
     * (PHP 5)<br/>
     * Get character api key in the db. Note that key are crypted
     * @return array of string
     */
    public static function get_character_api_key($user_id){
        $da = new character_DA();

        return $da->get_character_api_key($user_id);
    }

    /**
     * (PHP 5)<br/>
     * Check if the api key is a real one
     * @param string $api_key
     * @param bool $is_crypted
     * @return bool
     */
    public static function is_real_api_key($api_key, $is_crypted){

        $key = $is_crypted ? ryzom_decrypt($api_key) : $api_key;

        $uid=0;$slot=0;$full=false;

        return ryzom_character_valid_key($key, $uid, $slot, $full);
    }

    /**
     * (PHP 5)<br/>
     * Get character information
     * @param int $id
     * @return Character
     */
    public static function get_character($id){
        $da = new character_DA();

        return $da->get_character($id);
    }



}


class Character extends Guild_Member
{
    /**
     * (PHP 5)<br/>
     * Construct a Character instance
     */
    public function Character(){
        $this->char_DA = new character_DA();
    }

    private $char_DA;


    /** Set values functions **/

    /**
     * (PHP 5)<br/>
     * Set guild member general informations
     * @param int $id
     * @param string $name
     * @param string $shard
     * @param string $race
     * @param string $gender
     * @param string $titleid
     * @param int $money
     * @param int $grade_id
     * @param date $joined_date
     * @param date $last_update_date
     */
    public function set_general_information($id, $name, $shard, $race, $gender,
        $titleid, $money, $grade_id, $joined_date, $last_update_date, $guild_name, $guild_icon){

        parent::set_general_information($id, $name, $grade_id, $joined_date,
                $last_update_date, $guild_name, $guild_icon);
        $this->shard = $shard;
        $this->race = $race;
        $this->gender = $gender;
        $this->titleid = $titleid;
        $this->money = $money;

    }

    /**
     * (PHP 5)<br/>
     * Set guild member fight skill values
     * @param int $mace_1h
     * @param int $staff_1h
     * @param int $spear_1h
     * @param int $axe_1h
     * @param int $sword_1h
     * @param int $dagger_1h
     * @param int $mace_2h
     * @param int $pike_2h
     * @param int $axe_2h
     * @param int $sword_2h
     * @param int $hand_to_hand
     * @param int $pistol
     * @param int $autolauncher
     * @param int $launcher
     * @param int $rifle
     */
    public function set_fight_skill($mace_1h, $staff_1h, $spear_1h, $axe_1h, $sword_1h,
                    $dagger_1h, $mace_2h, $pike_2h, $axe_2h, $sword_2h, $hand_to_hand,
                    $pistol, $autolauncher, $launcher, $rifle){
        $this->mace_1h = $mace_1h;
        $this->staff_1h = $staff_1h;
        $this->spear_1h = $spear_1h;
        $this->axe_1h = $axe_1h;
        $this->sword_1h = $sword_1h;
        $this->dagger_1h = $dagger_1h;
        $this->mace_2h = $mace_2h;
        $this->pike_2h = $pike_2h;
        $this->axe_2h = $axe_2h;
        $this->sword_2h = $sword_2h;
        $this->hand_to_hand = $hand_to_hand;
        $this->pistol = $pistol;
        $this->autolauncher = $autolauncher;
        $this->launcher = $launcher;
        $this->rifle = $rifle;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member magic skill values
     * @param int $elemental_magic
     * @param int $offensive_affliction
     * @param int $healing_magic
     * @param int $defensive_affliction
     */
    public function set_magic_skill($elemental_magic, $offensive_affliction, $healing_magic, $defensive_affliction){
        $this->elemental_magic = $elemental_magic;
        $this->offensive_affiction = $offensive_affliction;
        $this->healing_magic = $healing_magic;
        $this->defensive_affliction = $defensive_affliction;

    }

    /**
     * (PHP 5)<br/>
     * Set guild member harvest skill values
     * @param int $desert_harvest
     * @param int $jungle_harvest
     * @param int $lake_harvest
     * @param int $prime_roots_harvest
     * @param int $forest_harvest
     */
    public function set_harvest_skill($desert_harvest, $jungle_harvest, $lake_harvest, $prime_roots_harvest, $forest_harvest){
        $this->desert_harvest = $desert_harvest;
        $this->jungle_harvest = $jungle_harvest;
        $this->lake_harvest = $lake_harvest;
        $this->prime_roots_harvest = $prime_roots_harvest;
        $this->forest_harvest = $forest_harvest;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member armor craft skill values
     * @param int $heavy_boot
     * @param int $heavy_glove
     * @param int $heavy_helmet
     * @param int $heavy_pant
     * @param int $heavy_sleeve
     * @param int $heavy_vest
     * @param int $medium_boot
     * @param int $medium_glove
     * @param int $medium_pant
     * @param int $medium_sleeve
     * @param int $medium_vest
     * @param int $light_boot
     * @param int $light_glove
     * @param int $light_pant
     * @param int $light_sleeve
     * @param int $light_vest
     * @param int $shield
     * @param int $large_shield
     */
    public function set_craft_armor_item_skill($heavy_boot, $heavy_glove, $heavy_helmet, $heavy_pant, $heavy_sleeve, $heavy_vest,
                    $medium_boot, $medium_glove, $medium_pant, $medium_sleeve, $medium_vest, $light_boot, $light_glove, $light_pant,
                    $light_sleeve, $light_vest, $shield, $large_shield){

        $this->craft_heavy_armor_boot = $heavy_boot;
        $this->craft_heavy_armor_glove = $heavy_glove;
        $this->craft_heavy_armor_helmet = $heavy_helmet;
        $this->craft_heavy_armor_pant = $heavy_pant;
        $this->craft_heavy_armor_sleeve = $heavy_sleeve;
        $this->craft_heavy_armor_vest = $heavy_vest;

        $this->craft_medium_armor_boot = $medium_boot;
        $this->craft_medium_armor_glove = $medium_glove;
        $this->craft_medium_armor_pant = $medium_pant;
        $this->craft_medium_armor_sleeve = $medium_sleeve;
        $this->craft_medium_armor_vest = $medium_vest;

        $this->craft_light_armor_boot = $light_boot;
        $this->craft_light_armor_glove = $light_glove;
        $this->craft_light_armor_pant = $light_pant;
        $this->craft_light_armor_sleeve = $light_sleeve;
        $this->craft_light_armor_vest = $light_vest;

        $this->craft_shield = $shield;
        $this->craft_large_shield = $large_shield;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member jewel craft skill values
     * @param int $anklet
     * @param int $bracelet
     * @param int $diadem
     * @param int $earring
     * @param int $pendant
     * @param int $ring
     */
    public function set_craft_jewel_item_skill($anklet, $bracelet, $diadem, $earring,
                    $pendant, $ring){
        $this->craft_jewel_anklet = $anklet;
        $this->craft_jewel_bracelet = $bracelet;
        $this->craft_jewel_diadem = $diadem;
        $this->craft_jewel_earring = $earring;
        $this->craft_jewel_pendant = $pendant;
        $this->craft_jewel_ring = $ring;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member weapon craft skill values
     * @param int $axe_1h
     * @param int $dagger_1h
     * @param int $mace_1h
     * @param int $spear_1h
     * @param int $sword_1h
     * @param int $staff_1h
     * @param int $axe_2h
     * @param int $mace_2h
     * @param int $pike_2h
     * @param int $sword_2h
     * @param int $ampli
     * @param int $pistol
     * @param int $autolauncher
     * @param int $launcher
     * @param int $rifle
     */
    public function set_craft_weapon_skill($axe_1h, $dagger_1h, $mace_1h, $spear_1h, $sword_1h, $staff_1h, $axe_2h, $mace_2h,
                    $pike_2h, $sword_2h, $ampli, $pistol, $autolauncher, $launcher, $rifle){
        
        $this->craft_axe_1h = $axe_1h;
        $this->craft_dagger_1h = $dagger_1h;
        $this->craft_mace_1h = $mace_1h;
        $this->craft_spear_1h = $spear_1h;
        $this->craft_sword_1h = $sword_1h;
        $this->craft_staff_1h = $staff_1h;

        $this->craft_axe_2h = $axe_2h;
        $this->craft_mace_2h = $mace_2h;
        $this->craft_pike_2h = $pike_2h;
        $this->craft_sword_2h = $sword_2h;

        $this->craft_ampli = $ampli;
        $this->craft_pistol = $pistol;
        $this->craft_autolauncher = $autolauncher;
        $this->craft_launcher = $launcher;
        $this->craft_rifle = $rifle;

    }

    /**
     * (PHP 5)<br/>
     * Set guild member statistics values
     * @param int $constitution
     * @param int $metabolism
     * @param int $intelligence
     * @param int $wisdom
     * @param int $strength
     * @param int $wellbalanced
     * @param int $dexterity
     * @param int $will
     * @param int $hitpoints
     * @param int $stamina
     * @param int $sap
     * @param int $focus
     */
    public function set_statistics($constitution, $metabolism, $intelligence, $wisdom, $strength, $wellbalanced, $dexterity,
                    $will, $hitpoints, $stamina, $sap, $focus){

        $this->constitution = $constitution;
        $this->metabolism = $metabolism;
        $this->intelligence = $intelligence;
        $this->wisdom = $wisdom;
        $this->strength = $strength;
        $this->wellbalanced = $wellbalanced;
        $this->dexterity = $dexterity;
        $this->will = $will;

        $this->hitpoints = $hitpoints;
        $this->stamina = $stamina;
        $this->sap = $sap;
        $this->focus = $focus;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member fame values
     * @param string $civization
     * @param string $cult
     * @param int $fyros_fame
     * @param int $matis_fame
     * @param int $tryker_fame
     * @param int $zorai_fame
     * @param int $kami_fame
     * @param int $karavan_fame
     * @param int $tribe_darkening_sap_fame
     * @param int $tribe_lawless_fame
     * @param int $tribe_leviers_fame
     * @param int $tribe_master_of_the_goo_fame
     * @param int $tribe_restorers_fame
     * @param int $tribe_scorchers_fame
     * @param int $tribe_water_breakers_fame
     */
    public function set_fame($civization, $cult, $fyros_fame, $matis_fame, $tryker_fame, $zorai_fame, $kami_fame, $karavan_fame,
                    $tribe_darkening_sap_fame, $tribe_lawless_fame, $tribe_leviers_fame, $tribe_master_of_the_goo_fame,
                    $tribe_restorers_fame, $tribe_scorchers_fame, $tribe_water_breakers_fame){

        $this->civilization = $civization;
        $this->cult = $cult;
        $this->fyros_fame = $fyros_fame;
        $this->kami_fame = $kami_fame;
        $this->karavan_fame = $karavan_fame;
        $this->matis_fame = $matis_fame;
        $this->tribe_darkening_sap_fame = $tribe_darkening_sap_fame;
        $this->tribe_lawless_fame = $tribe_lawless_fame;
        $this->tribe_leviers_fame = $tribe_leviers_fame;
        $this->tribe_master_of_the_goo_fame = $tribe_master_of_the_goo_fame;
        $this->tribe_restorers_fame = $tribe_restorers_fame;
        $this->tribe_scorchers_fame = $tribe_scorchers_fame;
        $this->tribe_water_breakers_fame = $tribe_water_breakers_fame;
        $this->tryker_fame = $tryker_fame;
        $this->zorai_fame = $zorai_fame;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member faction point values
     * @param int $fyros_point
     * @param int $matis_point
     * @param int $tryker_point
     * @param int $zorai_point
     * @param int $kami_point
     * @param int $karavan_point
     */
    public function set_faction_point($fyros_point, $matis_point, $tryker_point, $zorai_point, $kami_point, $karavan_point){
        $this->fyros_faction_point = $fyros_point;
        $this->matis_faction_point = $matis_point;
        $this->tryker_faction_point = $tryker_point;
        $this->zorai_faction_point = $zorai_point;
        $this->kami_faction_point = $kami_point;
        $this->karavan_faction_point = $karavan_point;

    }

    /**
     * (PHP 5)<br/>
     * Set guild member faction connection informations
     * @param int $played_time
     * @param date $latest_login
     * @param date $latest_logout
     * @param array of date $latest_connection
     */
    public function set_connection_information($played_time, $latest_login, $latest_logout, $latest_connection){
        $this->played_time = $played_time;
        $this->latest_login = $latest_login;
        $this->latest_logout = $latest_logout;
        $this->latest_connection = $latest_connection;
    }

    /**
     * (PHP 5)<br/>
     * Set guild member body informations 
     * @param int $hair_type
     * @param int $hair_color
     * @param int $tattoo
     * @param int $eyes_color
     * @param int $gabarit_height
     * @param int $gabarit_torso_width
     * @param int $gabarit_arms_width
     * @param int $gabarit_legs_width
     * @param int $gabarit_breast_size
     * @param int $morph1
     * @param int $morph2
     * @param int $morph3
     * @param int $morph4
     * @param int $morph5
     * @param int $morph6
     * @param int $morph7
     * @param int $morph8
     */
    public function set_body_information($hair_type, $hair_color, $tattoo, $eyes_color, $gabarit_height, $gabarit_torso_width,
                    $gabarit_arms_width, $gabarit_legs_width, $gabarit_breast_size, $morph1, $morph2, $morph3, $morph4,
                    $morph5, $morph6, $morph7, $morph8){

        $this->hair_type = $hair_type;
        $this->hair_color = $hair_color;
        $this->tattoo = $tattoo;
        $this->eyes_color = $eyes_color;
        $this->gabarit_height = $gabarit_height;
        $this->gabarit_torso_width = $gabarit_torso_width;
        $this->gabarit_arms_width = $gabarit_arms_width;
        $this->gabarit_legs_width = $gabarit_legs_width;
        $this->gabarit_breast_size = $gabarit_breast_size;
        $this->morph1 = $morph1;
        $this->morph2 = $morph2;
        $this->morph3 = $morph3;
        $this->morph4 = $morph4;
        $this->morph5 = $morph5;
        $this->morph6 = $morph6;
        $this->morph7 = $morph7;
        $this->morph8 = $morph8;
    }


    /**
     * (PHP 5)<br/>
     * Deserialize a character
     * @param SimpleXMLElement $xml. Serialized character
     * @param string $api_key
     * @param int $id
     */
    public function deserialize($xml, $api_key, $id){
        $this->id = $id;
        $this->api_key = $api_key;

        $this->name = $xml->name;
        $this->shard = $xml->shard;
        $this->race = $xml->race;
        $this->gender = $xml->gender;
        $this->titleid = $xml->titleid;
        $this->money = $xml->money;



        /** Connexion informations **/
        $this->played_time = $xml->played_time[0];
        $this->latest_login =  gmstrftime('%Y-%m-%d %H:%M:%S', (int)$xml->latest_login);
        $this->latest_logout = gmstrftime('%Y-%m-%d %H:%M:%S', (int)$xml->latest_logout);
        $this->latest_connection = $xml->latest_connection;

        /** Body informations **/
        $this->hair_type = $xml->body->hair_type;
        $this->hair_color = $xml->body->hair_color;
        $this->tattoo = $xml->body->tattoo;
        $this->eyes_color = $xml->body->eyes_color;
        $this->gabarit_height = $xml->body->gabarit_height;
        $this->gabarit_torso_width = $xml->body->gabarit_torso_width;
        $this->gabarit_arms_width = $xml->body->gabarit_arms_width;
        $this->gabarit_legs_width = $xml->body->gabarit_legs_width;
        $this->gabarit_breast_size = $xml->body->gabarit_breast_size;
        $this->morph1 = $xml->body->morph1;
        $this->morph2 = $xml->body->morph2;
        $this->morph3 = $xml->body->morph3;
        $this->morph4 = $xml->body->morph4;
        $this->morph5 = $xml->body->morph5;
        $this->morph6 = $xml->body->morph6;
        $this->morph7 = $xml->body->morph7;
        $this->morph8 = $xml->body->morph8;

        /** Fame Informations **/
        $this->civilization = $xml->civ;
        $this->cult = $xml->cult;
        $this->fyros_fame = floor($xml->fames->fyros / 6000);
        $this->kami_fame = floor($xml->fames->kami / 6000);
        $this->karavan_fame = floor($xml->fames->karavan / 6000);
        $this->matis_fame = floor($xml->fames->matis / 6000);
        $this->tribe_darkening_sap_fame = floor($xml->fames->tribe_darkening_sap / 6000);
        $this->tribe_lawless_fame = floor($xml->fames->tribe_lawless / 6000);
        $this->tribe_leviers_fame = floor($xml->fames->tribe_leviers / 6000);
        $this->tribe_master_of_the_goo_fame = floor($xml->fames->tribe_master_of_the_goo / 6000);
        $this->tribe_restorers_fame = floor($xml->fames->tribe_restorers / 6000);
        $this->tribe_scorchers_fame = floor($xml->fames->tribe_scorchers / 6000);
        $this->tribe_water_breakers_fame = floor($xml->fames->tribe_water_breakers / 6000);
        $this->tryker_fame = floor($xml->fames->tryker / 6000);
        $this->zorai_fame = floor($xml->fames->zorai / 6000);

        /** Faction Points **/
        $this->kami_faction_point = $xml->faction_points->kami;
        $this->karavan_faction_point = $xml->faction_points->karavan;
        $this->fyros_faction_point = $xml->faction_points->fyros;
        $this->matis_faction_point = $xml->faction_points->matis;
        $this->tryker_faction_point = $xml->faction_points->tryker;
        $this->zorai_faction_point = $xml->faction_points->zorai;


        /** Physical Caracs **/
        $this->constitution = $xml->phys_characs->constitution;
        $this->metabolism = $xml->phys_characs->metabolism;
        $this->intelligence = $xml->phys_characs->intelligence;
        $this->wisdom = $xml->phys_characs->wisdom;
        $this->strength = $xml->phys_characs->strength;
        $this->wellbalanced = $xml->phys_characs->wellbalanced;
        $this->dexterity = $xml->phys_characs->dexterity;
        $this->will = $xml->phys_characs->will;

        /** Physical Scores **/
        $this->hitpoints = $xml->phys_scores->hitpoints;
        $this->stamina = $xml->phys_scores->stamina;
        $this->sap = $xml->phys_scores->sap;
        $this->focus = $xml->phys_scores->focus;

        /** Equipement **/
        //TODO

        /** Skills **/
        /** Fight Skills **/
        $this->mace_1h = $this->get_skill_level($xml,'sfm1bmm');
        $this->staff_1h = $this->get_skill_level($xml,'sfm1bsm');
        $this->spear_1h = $this->get_skill_level($xml,'sfm1psm');
        $this->axe_1h = $this->get_skill_level($xml,'sfm1sam');
        $this->sword_1h = $this->get_skill_level($xml,'sfm1ssm');
        $this->dagger_1h = $this->get_skill_level($xml,'sfmcadm');
        $this->mace_2h = $this->get_skill_level($xml,'sfm2bmm');
        $this->pike_2h = $this->get_skill_level($xml,'sfm2ppm');
        $this->axe_2h = $this->get_skill_level($xml,'sfm2sam');
        $this->sword_2h = $this->get_skill_level($xml,'sfm2ssm');
        $this->hand_to_hand = $this->get_skill_level($xml,'sfmcahm');
        $this->pistol = $this->get_skill_level($xml,'sfr1apm');
        $this->autolauncher = $this->get_skill_level($xml,'sfr2aam');
        $this->launcher = $this->get_skill_level($xml,'sfr2alm');
        $this->rifle = $this->get_skill_level($xml,'sfr2arm');


        /** Magic Skills **/
        $this->elemental_magic = $this->get_skill_level($xml,'smoeaem');
        $this->offensive_affiction = $this->get_skill_level($xml,'smoaaem');
        $this->healing_magic = $this->get_skill_level($xml,'smdhaem');
        $this->defensive_affliction = $this->get_skill_level($xml,'smdaaem');


        /** Harvest Skills **/
        $this->desert_harvest = $this->get_skill_level($xml,'shfdaem');
        $this->jungle_harvest = $this->get_skill_level($xml,'shfjaem');
        $this->lake_harvest = $this->get_skill_level($xml,'shflaem');
        $this->prime_roots_harvest = $this->get_skill_level($xml,'shfpaem');
        $this->forest_harvest = $this->get_skill_level($xml,'shffaem');

        /** Craft Skills **/
        $this->craft_heavy_armor_boot = $this->get_skill_level($xml,'scahbem');
        $this->craft_heavy_armor_glove = $this->get_skill_level($xml,'scahgem');
        $this->craft_heavy_armor_helmet = $this->get_skill_level($xml,'scahhem');
        $this->craft_heavy_armor_pant = $this->get_skill_level($xml,'scahpem');
        $this->craft_heavy_armor_sleeve = $this->get_skill_level($xml,'scahsem');
        $this->craft_heavy_armor_vest = $this->get_skill_level($xml,'scahvem');

        $this->craft_medium_armor_boot = $this->get_skill_level($xml,'scambem');
        $this->craft_medium_armor_glove = $this->get_skill_level($xml,'scamgem');
        $this->craft_medium_armor_pant = $this->get_skill_level($xml,'scampem');
        $this->craft_medium_armor_sleeve = $this->get_skill_level($xml,'scamsem');
        $this->craft_medium_armor_vest = $this->get_skill_level($xml,'scamvem');

        $this->craft_light_armor_boot = $this->get_skill_level($xml,'scalbem');
        $this->craft_light_armor_glove = $this->get_skill_level($xml,'scalgem');
        $this->craft_light_armor_pant = $this->get_skill_level($xml,'scalpem');
        $this->craft_light_armor_sleeve = $this->get_skill_level($xml,'scalsem');
        $this->craft_light_armor_vest = $this->get_skill_level($xml,'scalvem');

        $this->craft_shield = $this->get_skill_level($xml,'scasbem');
        $this->craft_large_shield = $this->get_skill_level($xml,'scaslem');

        $this->craft_jewel_anklet = $this->get_skill_level($xml,'scjaaem');
        $this->craft_jewel_bracelet = $this->get_skill_level($xml,'scjbaem');
        $this->craft_jewel_diadem = $this->get_skill_level($xml,'scjdaem');
        $this->craft_jewel_earring = $this->get_skill_level($xml,'scjeaem');
        $this->craft_jewel_pendant = $this->get_skill_level($xml,'scjpaem');
        $this->craft_jewel_ring = $this->get_skill_level($xml,'scjraem');

        $this->craft_axe_1h = $this->get_skill_level($xml,'scm1aem');
        $this->craft_dagger_1h = $this->get_skill_level($xml,'scm1dem');
        $this->craft_mace_1h = $this->get_skill_level($xml,'scm1mem');
        $this->craft_spear_1h = $this->get_skill_level($xml,'scm1pem');
        $this->craft_sword_1h = $this->get_skill_level($xml,'scm1sem');
        $this->craft_staff_1h = $this->get_skill_level($xml,'scm1tem');

        $this->craft_axe_2h = $this->get_skill_level($xml,'scm2aem');
        $this->craft_mace_2h = $this->get_skill_level($xml,'scm2mem');
        $this->craft_pike_2h = $this->get_skill_level($xml,'scm2pem');
        $this->craft_sword_2h = $this->get_skill_level($xml,'scm2sem');

        $this->craft_ampli = $this->get_skill_level($xml,'scmcaem');
        $this->craft_pistol = $this->get_skill_level($xml,'scr1pem');
        $this->craft_autolauncher = $this->get_skill_level($xml,'scr2aem');
        $this->craft_launcher = $this->get_skill_level($xml,'scr2lem');
        $this->craft_rifle = $this->get_skill_level($xml,'scr2rem');



        $this->char_DA->save_character($this);
    }
	
	/***************************************************/
	/*                Properties 			   */
	/***************************************************/

    private $api_key;
    /**
     * (PHP 5)<br/>
     * Get character api key
     * @return string
     */
    public function get_api_key(){
        return $this->api_key;
    }


    private $id_guild;
    /**
     * (PHP 5)<br/>
     * Get the character guild id
     * @return int
     */
    public function get_id_guild(){
        return $this->id_guild;
    }

    private $shard;
    /**
     * (PHP 5)<br/>
     * Get the character shard
     * @return string
     */
    public function get_shard(){
            return $this->shard;
    }

    private $race;
    /**
     * (PHP 5)<br/>
     * Get the character race
     * @return string
     */
    public function get_race(){
            return $this->race;
    }

    private $gender;
    /**
     * (PHP 5)<br/>
     * Get the character gender
     * @return string
     */
    public function get_gender(){
            return $this->gender;
    }

    private $titleid;
    /**
     * (PHP 5)<br/>
     * Get the character title id
     * @return string
     */
    public function get_titleid(){
            return $this->titleid;
    }

    private $money;
    /**
     * (PHP 5)<br/>
     * Get the character money
     * @return int
     */
    public function get_money(){
            return $this->money;
    }


    /** Connexion informations **/
    private $played_time;
    /**
     * (PHP 5)<br/>
     * Get the character played time
     * @return int
     */
    public function get_played_time(){
        //convert int value to string
        $num=abs($this->played_time);
	$sec=$num%60;
	$min=floor(($num/60)%60);
	$hour=floor(($num/3600)%24);
	$days=floor(($num/86400));
        $result = $days.' '.Language::get_instance()->get_label('lb_days').', '
                        .$hour.' '.Language::get_instance()->get_label('lb_hours').', '
                        .$min.' '.Language::get_instance()->get_label('lb_minutes').', '
                        .$sec.' '.Language::get_instance()->get_label('lb_seconds');

        return $result;
    }

    private $latest_login;
    /**
     * (PHP 5)<br/>
     * Get the character last login date
     * @return date
     */
    public function get_latest_login(){
            return $this->latest_login;
    }

    private $latest_logout;
    /**
     * (PHP 5)<br/>
     * Get the character last logout date
     * @return date
     */
    public function get_latest_logout(){
            return $this->latest_logout;
    }

    private $latest_connection;
    //TODO : make the function get_latest_connection() work
    /*public function get_latest_connection(){
            return $this->latest_connection;
    }*/


    /** Body Informations **/
    private $hair_type;
    /**
     * (PHP 5)<br/>
     * Get the character hair type
     * @return int
     */
    public function get_hair_type(){
            return $this->hair_type;
    }

    private $hair_color;
    /**
     * (PHP 5)<br/>
     * Get the character hair color
     * @return int
     */
    public function get_hair_color(){
            return $this->hair_color;
    }

    private $tattoo;
    /**
     * (PHP 5)<br/>
     * Get the character tattoo
     * @return int
     */
    public function get_tattoo(){
            return $this->tattoo;
    }

    private $eyes_color;
    /**
     * (PHP 5)<br/>
     * Get the character eyes color
     * @return int
     */
    public function get_eyes_color(){
            return $this->eyes_color;
    }

    private $gabarit_height;
    /**
     * (PHP 5)<br/>
     * Get the character gabarit height
     * @return int
     */
    public function get_gabarit_height(){
            return $this->gabarit_height;
    }

    private $gabarit_torso_width;
    /**
     * (PHP 5)<br/>
     * Get the character gabarit torso width
     * @return int
     */
    public function get_gabarit_torso_width(){
            return $this->gabarit_torso_width;
    }

    private $gabarit_arms_width;
    /**
     * (PHP 5)<br/>
     * Get the character gabarit arms width
     * @return int
     */
    public function get_gabarit_arms_width(){
            return $this->gabarit_arms_width;
    }

    private $gabarit_legs_width;
    /**
     * (PHP 5)<br/>
     * Get the character gabarit legs width
     * @return int
     */
    public function get_gabarit_legs_width(){
            return $this->gabarit_legs_width;
    }

    private $gabarit_breast_size;
    /**
     * (PHP 5)<br/>
     * Get the character gabarit breast size
     * @return int
     */
    public function get_gabarit_breast_size(){
            return $this->gabarit_breast_size;
    }

    private $morph1;
    /**
     * (PHP 5)<br/>
     * Get the character morph1
     * @return int
     */
    public function get_morph1(){
            return $this->morph1;
    }

    private $morph2;
    /**
     * (PHP 5)<br/>
     * Get the character morph2
     * @return int 
     */
    public function get_morph2(){
            return $this->morph2;
    }

    private $morph3;
    /**
     * (PHP 5)<br/>
     * Get the character morph3
     * @return int
     */
    public function get_morph3(){
            return $this->morph3;
    }
    private $morph4;
    /**
     * (PHP 5)<br/>
     * Get the character morph4
     * @return int
     */
    public function get_morph4(){
            return $this->morph4;
    }

    private $morph5;
    /**
     * (PHP 5)<br/>
     * Get the character morph5
     * @return int
     */
    public function get_morph5(){
            return $this->morph5;
    }

    private $morph6;
    /**
     * (PHP 5)<br/>
     * Get the character morph6
     * @return int
     */
    public function get_morph6(){
            return $this->morph6;
    }

    private $morph7;
    /**
     * (PHP 5)<br/>
     * Get the character morph7
     * @return int
     */
    public function get_morph7(){
            return $this->morph7;
    }

    private $morph8;
    /**
     * (PHP 5)<br/>
     * Get the character morph8
     * @return int
     */
    public function get_morph8(){
            return $this->morph8;
    }

    /** Fame Informations**/
    private $civilization;
    /**
     * (PHP 5)<br/>
     * Get the character civilization
     * @return string
     */
    public function get_civilization(){
            return $this->civilization;
    }

    private $cult;
    /**
     * (PHP 5)<br/>
     * Get the character cult
     * @return int
     */
    public function get_cult(){
            return $this->cult;
    }

    private $fyros_fame;
    /**
     * (PHP 5)<br/>
     * Get the character fyros fame
     * @return int
     */
    public function get_fyros_fame(){
            return $this->fyros_fame;
    }

    private $kami_fame;
    /**
     * (PHP 5)<br/>
     * Get the character kami fame
     * @return int
     */
    public function get_kami_fame(){
            return $this->kami_fame;
    }

    private $karavan_fame;
    /**
     * (PHP 5)<br/>
     * Get the character karavan fame
     * @return int
     */
    public function get_karavan_fame(){
            return $this->karavan_fame;
    }

    private $matis_fame;
    /**
     * (PHP 5)<br/>
     * Get the character matis fame
     * @return int
     */
    public function get_matis_fame(){
            return $this->matis_fame;
    }

    private $tribe_darkening_sap_fame;
    /**
     * (PHP 5)<br/>
     * Get the character darkenig sap fame
     * @return int
     */
    public function get_tribe_darkening_sap_fame(){
            return $this->tribe_darkening_sap_fame;
    }

    private $tribe_lawless_fame;
    /**
     * (PHP 5)<br/>
     * Get the character lawless fame
     * @return int
     */
    public function get_tribe_lawless_fame(){
            return $this->tribe_lawless_fame;
    }

    private $tribe_leviers_fame;
    /**
     * (PHP 5)<br/>
     * Get the character leviers fame
     * @return int
     */
    public function get_tribe_leviers_fame(){
            return $this->tribe_leviers_fame;
    }

    private $tribe_master_of_the_goo_fame;
    /**
     * (PHP 5)<br/>
     * Get the character masters of the goo fame
     * @return int
     */
    public function get_tribe_master_of_the_goo_fame(){
            return $this->tribe_master_of_the_goo_fame;
    }

    private $tribe_restorers_fame;
    /**
     * (PHP 5)<br/>
     * Get the character restorers fame
     * @return int
     */
    public function get_tribe_restorers_fame(){
            return $this->tribe_restorers_fame;
    }

    private $tribe_scorchers_fame;
    /**
     * (PHP 5)<br/>
     * Get the character scrochers fame
     * @return int
     */
    public function get_tribe_scorchers_fame(){
            return $this->tribe_scorchers_fame;
    }

    private $tribe_water_breakers_fame;
    /**
     * (PHP 5)<br/>
     * Get the character water breakers fame
     * @return int
     */
    public function get_tribe_water_breakers_fame(){
            return $this->tribe_water_breakers_fame;
    }

    private $tryker_fame;
    /**
     * (PHP 5)<br/>
     * Get the character tryker fame
     * @return int
     */
    public function get_tryker_fame(){
            return $this->tryker_fame;
    }

    private $zorai_fame;
    /**
     * (PHP 5)<br/>
     * Get the character zorai fame
     * @return int
     */
    public function get_zorai_fame(){
            return $this->zorai_fame;
    }

    /** Faction Points **/

    private $kami_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character kami faction point
     * @return int
     */
    public function get_kami_faction_point(){
            return $this->kami_faction_point;
    }

    private $karavan_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character karavan faction point
     * @return int
     */
    public function get_karavan_faction_point(){
            return $this->karavan_faction_point;
    }

    private $fyros_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character fyros faction point
     * @return int
     */
    public function get_fyros_faction_point(){
            return $this->fyros_faction_point;
    }

    private $matis_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character matis faction point
     * @return int
     */
    public function get_matis_faction_point(){
            return $this->matis_faction_point;
    }

    private $tryker_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character tryker faction point
     * @return int
     */
    public function get_tryker_faction_point(){
            return $this->tryker_faction_point;
    }

    private $zorai_faction_point;
    /**
     * (PHP 5)<br/>
     * Get the character zorai faction point
     * @return int
     */
    public function get_zorai_faction_point(){
            return $this->zorai_faction_point;
    }


    /** Physical Caracs **/
    private $constitution;
    /**
     * (PHP 5)<br/>
     * Get the character constitution 
     * @return int
     */
    public function get_constitution(){
            return $this->constitution;
    }

    private $metabolism;
    /**
     * (PHP 5)<br/>
     * Get the character metabolism
     * @return int
     */
    public function get_metabolism(){
            return $this->metabolism;
    }

    private $intelligence;
    /**
     * (PHP 5)<br/>
     * Get the character intelligence
     * @return int
     */
    public function get_intelligence(){
            return $this->intelligence;
    }

    private $wisdom;
    /**
     * (PHP 5)<br/>
     * Get the character wisdom
     * @return int
     */
    public function get_wisdom(){
            return $this->wisdom;
    }

    private $strength;
    /**
     * (PHP 5)<br/>
     * Get the character strength
     * @return int
     */
    public function get_strength(){
            return $this->strength;
    }

    private $wellbalanced;
    /**
     * (PHP 5)<br/>
     * Get the character wellbalanced
     * @return int
     */
    public function get_wellbalanced(){
            return $this->wellbalanced;
    }

    private $dexterity;
    /**
     * (PHP 5)<br/>
     * Get the character dexterity
     * @return int
     */
    public function get_dexterity(){
            return $this->dexterity;
    }

    private $will;
    /**
     * (PHP 5)<br/>
     * Get the character will
     * @return int
     */
    public function get_will(){
            return $this->will;
    }

    /** Physical Scores **/
    private $hitpoints;
    /**
     * (PHP 5)<br/>
     * Get the character hit points
     * @return int
     */
    public function get_hit_points(){
            return $this->hitpoints;
    }
    /**
     * (PHP 5)<br/>
     * Get the character hit points regeneration
     * @return int
     */
    public function get_hit_points_regen(){
        return $this->metabolism / 2;
    }
    
    private $stamina;
    /**
     * (PHP 5)<br/>
     * Get the character stamina points
     * @return int
     */
    public function get_stamina(){
            return $this->stamina;
    }
    /**
     * (PHP 5)<br/>
     * Get the character stamina points regeneration
     * @return int
     */
    public function get_stamina_regen(){
        return $this->wellbalanced / 2;
    }
    
    private $sap;
    /**
     * (PHP 5)<br/>
     * Get the character sap points
     * @return int
     */
    public function get_sap(){
            return $this->sap;
    }
    /**
     * (PHP 5)<br/>
     * Get the character sap points regeneration
     * @return int
     */
    public function get_sap_regen(){
        return $this->wisdom / 2;
    }

    private $focus;
    /**
     * (PHP 5)<br/>
     * Get the character focus points
     * @return int
     */
    public function get_focus(){
            return $this->focus;
    }
    /**
     * (PHP 5)<br/>
     * Get the character focus regeneration points
     * @return int
     */
    public function get_focus_regen(){
        return $this->will / 2;
    }


    /** Skills **/

    /** Fight Skills **/
    private $mace_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand mace skill
     * @return int
     */
    public function get_mace_1h(){
            return $this->mace_1h;
    }

    private $staff_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand staff skill
     * @return int
     */
    public function get_staff_1h(){
            return $this->staff_1h;
    }

    private $spear_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand spear skill
     * @return int
     */
    public function get_spear_1h(){
            return $this->spear_1h;
    }

    private $axe_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand axe skill
     * @return int
     */
    public function get_axe_1h(){
            return $this->axe_1h;
    }
    private $sword_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand sword skill
     * @return int
     */
    public function get_sword_1h(){
            return $this->sword_1h;
    }

    private $dagger_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand dagger skill
     * @return int
     */
    public function get_dagger_1h(){
            return $this->dagger_1h;
    }

    private $mace_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands mace skill
     * @return int
     */
    public function get_mace_2h(){
            return $this->mace_2h;
    }

    private $pike_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands pike skill
     * @return int
     */
    public function get_pike_2h(){
            return $this->pike_2h;
    }

    private $axe_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands axe skill
     * @return int
     */
    public function get_axe_2h(){
            return $this->axe_2h;
    }

    private $sword_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands sword skill
     * @return int
     */
    public function get_sword_2h(){
            return $this->sword_2h;
    }

    private $hand_to_hand;
    /**
     * (PHP 5)<br/>
     * Get the character hand to hand skill
     * @return int
     */
    public function get_hand_to_hand(){
            return $this->hand_to_hand;
    }

    private $pistol;
    /**
     * (PHP 5)<br/>
     * Get the character pistol skill
     * @return int
     */
    public function get_pistol(){
            return $this->pistol;
    }

    private $autolauncher;
    /**
     * (PHP 5)<br/>
     * Get the character autolauncher skill
     * @return int
     */
    public function get_autolauncher(){
            return $this->autolauncher;
    }

    private $launcher;
    /**
     * (PHP 5)<br/>
     * Get the character launcher skill
     * @return int
     */
    public function get_launcher(){
            return $this->launcher;
    }

    private $rifle;
    /**
     * (PHP 5)<br/>
     * Get the character rifle skill
     * @return int
     */
    public function get_rifle(){
            return $this->rifle;
    }


    /** Magic Skills **/
    private $elemental_magic;
    /**
     * (PHP 5)<br/>
     * Get the character elemental magic skill
     * @return int
     */
    public function get_elemental_magic(){
            return $this->elemental_magic;
    }

    private $offensive_affiction;
    /**
     * (PHP 5)<br/>
     * Get the character offensive affliction skill
     * @return int
     */
    public function get_offensive_affiction(){
            return $this->offensive_affiction;
    }

    private $healing_magic;
    /**
     * (PHP 5)<br/>
     * Get the character healing magic skill
     * @return int
     */
    public function get_healing_magic(){
            return $this->healing_magic;
    }

    private $defensive_affliction;
    /**
     * (PHP 5)<br/>
     * Get the character defensive affliction skill
     * @return int
     */
    public function get_defensive_affliction(){
            return $this->defensive_affliction;
    }


    /** Harvest Skills **/
    private $desert_harvest;
    /**
     * (PHP 5)<br/>
     * Get the character desert harvest skill
     * @return int
     */
    public function get_desert_harvest(){
            return $this->desert_harvest;
    }

    private $jungle_harvest;
    /**
     * (PHP 5)<br/>
     * Get the character jungle harvest skill
     * @return int
     */
    public function get_jungle_harvest(){
            return $this->jungle_harvest;
    }

    private $lake_harvest;
    /**
     * (PHP 5)<br/>
     * Get the character lake harvest skill
     * @return int
     */
    public function get_lake_harvest(){
            return $this->lake_harvest;
    }

    private $prime_roots_harvest;
    /**
     * (PHP 5)<br/>
     * Get the character prime root harvest skill
     * @return int
     */
    public function get_prime_roots_harvest(){
            return $this->prime_roots_harvest;
    }

    private $forest_harvest;
    /**
     * (PHP 5)<br/>
     * Get the character forest harvest skill
     * @return int
     */
    public function get_forest_harvest(){
            return $this->forest_harvest;
    }



    /** Craft Skills **/
    private $craft_heavy_armor_boot;
    /**
     * (PHP 5)<br/>
     * Get the character heavy boot craft skill
     * @return int
     */
    public function get_craft_heavy_armor_boot(){
            return $this->craft_heavy_armor_boot;
    }

    private $craft_heavy_armor_glove;
    /**
     * (PHP 5)<br/>
     * Get the character heavy glove craft skill
     * @return int
     */
    public function get_craft_heavy_armor_glove(){
            return $this->craft_heavy_armor_glove;
    }

    private $craft_heavy_armor_helmet;
    /**
     * (PHP 5)<br/>
     * Get the character heavy helmet craft skill
     * @return int
     */
    public function get_craft_heavy_armor_helmet(){
            return $this->craft_heavy_armor_helmet;
    }

    private $craft_heavy_armor_pant;
    /**
     * (PHP 5)<br/>
     * Get the character heavy pant craft skill
     * @return int
     */
    public function get_craft_heavy_armor_pant(){
            return $this->craft_heavy_armor_pant;
    }

    private $craft_heavy_armor_sleeve;
    /**
     * (PHP 5)<br/>
     * Get the character heavy sleeve craft skill
     * @return int
     */
    public function get_craft_heavy_armor_sleeve(){
            return $this->craft_heavy_armor_sleeve;
    }

    private $craft_heavy_armor_vest;
    /**
     * (PHP 5)<br/>
     * Get the character heavy vest craft skill
     * @return int
     */
    public function get_craft_heavy_armor_vest(){
            return $this->craft_heavy_armor_vest;
    }

    private $craft_medium_armor_boot;
    /**
     * (PHP 5)<br/>
     * Get the character medium boot craft skill
     * @return int
     */
    public function get_craft_medium_armor_boot(){
            return $this->craft_medium_armor_boot;
    }

    private $craft_medium_armor_glove;
    /**
     * (PHP 5)<br/>
     * Get the character medium glove craft skill
     * @return int
     */
    public function get_craft_medium_armor_glove(){
            return $this->craft_medium_armor_glove;
    }

    private $craft_medium_armor_pant;
    /**
     * (PHP 5)<br/>
     * Get the character medium pant craft skill
     * @return int
     */
    public function get_craft_medium_armor_pant(){
            return $this->craft_medium_armor_pant;
    }

    private $craft_medium_armor_sleeve;
    /**
     * (PHP 5)<br/>
     * Get the character medium sleeve craft skill
     * @return int
     */
    public function get_craft_medium_armor_sleeve(){
            return $this->craft_medium_armor_sleeve;
    }

    private $craft_medium_armor_vest;
    /**
     * (PHP 5)<br/>
     * Get the character medium vest craft skill
     * @return int
     */
    public function get_craft_medium_armor_vest(){
            return $this->craft_medium_armor_vest;
    }

    private $craft_light_armor_boot;
    /**
     * (PHP 5)<br/>
     * Get the character light boot craft skill
     * @return int
     */
    public function get_craft_light_armor_boot(){
            return $this->craft_light_armor_boot;
    }

    private $craft_light_armor_glove;
    /**
     * (PHP 5)<br/>
     * Get the character light glove craft skill
     * @return int
     */
    public function get_craft_light_armor_glove(){
            return $this->craft_light_armor_glove;
    }

    private $craft_light_armor_pant;
    /**
     * (PHP 5)<br/>
     * Get the character light pant craft skill
     * @return int
     */
    public function get_craft_light_armor_pant(){
            return $this->craft_light_armor_pant;
    }

    private $craft_light_armor_sleeve;
    /**
     * (PHP 5)<br/>
     * Get the character light sleeve craft skill
     * @return int
     */
    public function get_craft_light_armor_sleeve(){
            return $this->craft_light_armor_sleeve;
    }

    private $craft_light_armor_vest;
    /**
     * (PHP 5)<br/>
     * Get the character light vest craft skill
     * @return int
     */
    public function get_craft_light_armor_vest(){
            return $this->craft_light_armor_vest;
    }

    private $craft_shield;
    /**
     * (PHP 5)<br/>
     * Get the character shield craft skill
     * @return int
     */
    public function get_craft_shield(){
            return $this->craft_shield;
    }

    private $craft_large_shield;
    /**
     * (PHP 5)<br/>
     * Get the character large shield craft skill
     * @return int
     */
    public function get_craft_large_shield(){
            return $this->craft_large_shield;
    }

    private $craft_jewel_anklet;
    /**
     * (PHP 5)<br/>
     * Get the character anklet craft skill
     * @return int
     */
    public function get_craft_jewel_anklet(){
            return $this->craft_jewel_anklet;
    }

    private $craft_jewel_bracelet;
    /**
     * (PHP 5)<br/>
     * Get the character bracelet craft skill
     * @return int
     */
    public function get_craft_jewel_bracelet(){
            return $this->craft_jewel_bracelet;
    }

    private $craft_jewel_diadem;
    /**
     * (PHP 5)<br/>
     * Get the character diadem craft skill
     * @return int
     */
    public function get_craft_jewel_diadem(){
            return $this->craft_jewel_diadem;
    }

    private $craft_jewel_earring;
    /**
     * (PHP 5)<br/>
     * Get the character earring craft skill
     * @return int
     */
    public function get_craft_jewel_earring(){
            return $this->craft_jewel_earring;
    }

    private $craft_jewel_pendant;
    /**
     * (PHP 5)<br/>
     * Get the character pendant craft skill
     * @return int
     */
    public function get_craft_jewel_pendant(){
            return $this->craft_jewel_pendant;
    }

    private $craft_jewel_ring;
    /**
     * (PHP 5)<br/>
     * Get the character ring craft skill
     * @return int
     */
    public function get_craft_jewel_ring(){
            return $this->craft_jewel_ring;
    }

    private $craft_axe_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand axe craft skill
     * @return int
     */
    public function get_craft_axe_1h(){
            return $this->craft_axe_1h;
    }

    private $craft_dagger_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand dagger craft skill
     * @return int
     */
    public function get_craft_dagger_1h(){
            return $this->craft_dagger_1h;
    }

    private $craft_mace_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand mace craft skill
     * @return int
     */
    public function get_craft_mace_1h(){
            return $this->craft_mace_1h;
    }

    private $craft_spear_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand spear craft skill
     * @return int
     */
    public function get_craft_spear_1h(){
            return $this->craft_spear_1h;
    }

    private $craft_sword_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand axe craft skill
     * @return int
     */
    public function get_craft_sword_1h(){
            return $this->craft_sword_1h;
    }

    private $craft_staff_1h;
    /**
     * (PHP 5)<br/>
     * Get the character 1 hand staff craft skill
     * @return int
     */
    public function get_craft_staff_1h(){
            return $this->craft_staff_1h;
    }

    private $craft_axe_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands axe craft skill
     * @return int
     */
    public function get_craft_axe_2h(){
            return $this->craft_axe_2h;
    }

    private $craft_mace_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands mace craft skill
     * @return int
     */
    public function get_craft_mace_2h(){
            return $this->craft_mace_2h;
    }

    private $craft_pike_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands pike craft skill
     * @return int
     */
    public function get_craft_pike_2h(){
            return $this->craft_pike_2h;
    }

    private $craft_sword_2h;
    /**
     * (PHP 5)<br/>
     * Get the character 2 hands sword craft skill
     * @return int
     */
    public function get_craft_sword_2h(){
            return $this->craft_sword_2h;
    }

    private $craft_ampli;
    /**
     * (PHP 5)<br/>
     * Get the character amplifier craft skill
     * @return int
     */
    public function get_craft_ampli(){
            return $this->craft_ampli;
    }

    private $craft_pistol;
    /**
     * (PHP 5)<br/>
     * Get the character pistol craft skill
     * @return int
     */
    public function get_craft_pistol(){
            return $this->craft_pistol;
    }

    private $craft_autolauncher;
    /**
     * (PHP 5)<br/>
     * Get the character autolauncher craft skill
     * @return int
     */
    public function get_craft_autolauncher(){
            return $this->craft_autolauncher;
    }

    private $craft_launcher;
    /**
     * (PHP 5)<br/>
     * Get the character launcher craft skill
     * @return int
     */
    public function get_craft_launcher(){
            return $this->craft_launcher;
    }

    private $craft_rifle;
    /**
     * (PHP 5)<br/>
     * Get the character rifle craft skill
     * @return int
     */
    public function get_craft_rifle(){
            return $this->craft_rifle;
    }

    /**
     * (PHP 5)<br/>
     * Get the character pvp ally (based on faction fame)
     * @return int
     */
    public function get_pvp_ally(){
        //TODO : implement
        return 'TO IMPLEMENT';
    }



    /**
     * (PHP 5)<br/>
     * Extract the level of a skill from xml
     * @param SimpleXMLElement $xml
     * @param string $code
     * @return int
     */
    private function get_skill_level($xml, $code){
        $level = 1;

        

        //searching the level through the skills tree
        for ($i = 2; $i <= strlen($code); $i++) {
            $array = $xml->xpath('/character/skills/'.substr($code,0,$i));

            if (count($array) > 0){
                $level = $array[0];
            }
        }

        return $level;
    }
}

?>
